package com.blb.thread;

public class Work5 {

    public static void main(String[] args) {
        new Thread(() -> {
            for (int i = 1; i <= 1000; i++) {
                System.out.println("乌龟在跑" + i);
                if(i % 100 == 0){
                    try {
                        System.out.println("乌龟休息一下");
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
            System.out.println("乌龟到达终点");
        }).start();
        new Thread(() -> {
            for (int i = 1; i <= 1000; i += 5) {
                System.out.println("兔子在跑" + i);
                if(i % 20 == 0){
                    try {
                        System.out.println("兔子休息一下");
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
            System.out.println("兔子到达终点");
        }).start();
    }
}
